/* 编写函数,将数组中重复的属性删除 */
const arr = [1, 2, 3, 5, 1, 5, 9, 1, 2, 8]

const uniqueArray = (arr) => {
    let res = []   
    for (let i = 0; i < arr.length; i++) {
        let temp = arr[i]       
        if (res.indexOf(temp)==-1) {
            res.push(temp)
        }
    } 
    return res
}
console.log(uniqueArray(arr)); 

const uniqueArray2 = (arr) => {
    let res = []
    let map = {}
    for (let i = 0; i < arr.length; i++) {
        let temp = arr[i]
        if (!map.hasOwnProperty(temp)) {           
           map[temp]=i                     
            res.push(temp)
        }
    }   
    return res
}
console.log(uniqueArray2(arr)); 







